<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

	<xsl:template match="/">
		<html>
			<head>
				<title>Sophia Command Definitions</title>
				<link rel="stylesheet" href="commands.css" TYPE="text/css"/> 
			</head>
			<!-- <body class="document_body"> -->
			<body>
				<H2>Sophia Command Definitions</H2> 
				<xsl:apply-templates select="commands"/>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="commands">
		<p>Command definition version = <xsl:value-of select="@version"/></p>
		<xsl:apply-templates select="command">
			<xsl:sort select="@name" order="ascending"/>
		</xsl:apply-templates>
	</xsl:template>

	<xsl:template match="command">
		<!-- Name and Description -->
		<div class="med_title"><xsl:value-of select="@name"/></div>
		<div class="description"><xsl:value-of select="description"/></div>
		<xsl:if test="createsrows='True'">
			<i><div class="description">This command spools result rows</div></i>
		</xsl:if>
		<xsl:if test="returnsrows='True'">
			<i><div class="description">This command returns spooled result rows</div></i>
		</xsl:if>
		<!-- Parameter list if available -->
		<xsl:if test="count(parameter)>0">
			<div class="small_title">Parameters:</div>
			<table class="table">
			<xsl:apply-templates select="parameter"/>
			</table>
		</xsl:if>
		<!-- Response values if available -->
		<xsl:if test="count(responsevalue)>0">
			<div class="small_title">Return Value(s):</div>
			<table class="table">
			<xsl:apply-templates select="responsevalue"/>
			</table>
		</xsl:if>		
		<!-- Response line if available -->
		<xsl:if test="count(responseline)>0">
			<div class="small_title">Row Format:</div>
			<table class="table">
			<xsl:apply-templates select="responseline/value"/>
			</table>
		</xsl:if>		
	</xsl:template>
	
	<xsl:template match="parameter">
		<tr>
			<td width="20%"><xsl:value-of select="@name"/></td>
			<td width="20%"><xsl:value-of select="type"/></td>
			<td width="20%">
				<xsl:if test="mandatory='True'">Mandatory</xsl:if>
				<xsl:if test="mandatory!='True'">Optional</xsl:if>
			</td>
			<td width="*"><xsl:value-of select="description"/></td>
		</tr>
	</xsl:template>

	<xsl:template match="responsevalue">
		<tr>
			<td width="20%"><xsl:value-of select="@name"/></td>
			<td width="20%"><xsl:value-of select="type"/></td>
			<td width="*"><xsl:value-of select="description"/></td>
		</tr>
	</xsl:template>

	<xsl:template match="responseline/value">
		<tr>
			<td width="20%"><xsl:value-of select="@name"/></td>
			<td width="20%"><xsl:value-of select="type"/></td>
			<td width="*"><xsl:value-of select="description"/></td>
		</tr>
	</xsl:template>

</xsl:stylesheet>

  